<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            border: 1px solid red;
        }
        /*#d1{*/
        /*    position: absolute;*/
        /*    !*脱离文档流，相对于窗口（或上级元素）做偏移*!*/
        /*    right: 0px;*/
        /*    bottom: 0px;*/
        /*}*/

        #d2{
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 100px 0 0 100px;

        }
        #d2>div{
            width: 100px;
            height: 100px;
            margin: 50px 0 0 50px;
            background-color: blue;

            position: relative;/*做参照物*/
        }
        #d2>div>div{
            width: 50px;
            height: 50px;
            background-color: green;
            position: absolute;
            /*给上级元素设置为相对，本级的绝对就不会朝窗口跑，而是会朝着篮筐跑*/
            top: 0px;
            left: 0px;
        }
    </style>
</head>
<body>
<div id="d2">
    <div>
        <div></div>
    </div>
</div>
<div id="d1">div1</div>
<div>div2</div>
<div>div3</div>
</body>
</html>